<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <style>
        .text-c {text-align: center;}
        .text-l {text-align: left;}
        .text-r {text-align: right;}
        .c-red {color:red;}
        .table { border-collapse: separate;width: 100%; empty-cells: show;background-color: transparent;}
        .table-border {border: 1px solid #ddd;}
        .table-border th, .table-border td { border-bottom: 1px solid #ddd;}
        .btn { padding: 4px 12px; display: inline-block; box-sizing: border-box; cursor: pointer; text-align: center; font-weight: 400; white-space: nowrap; vertical-align: middle; border: solid 1px #ddd; background-color: #fff; width: auto; transition: background-color .1s linear;}
        .btn-success { color: #fff; background-color: #5eb95e; border-color: #5eb95e;}
        .btn-danger { color: #fff; background-color: #dd514c; border-color: #dd514c;}
        .btn-default { background-color: #e6e6e6;border-color: #e6e6e6;}
        .radius { border-radius: 4px; }
    </style>
</head>

<body>
    <article>
		{empty name="is_table"}
		<div></div>
		{else/}
		
		{/empty}
        <form action="{:url('tableColumn','id='.$data_table['id'])}" method="post" id="form-admin-tableColumn">
            <table class="table table-border">
				<thead>
					<tr class="text-c">
						<!-- <th width="60px">ID</th> -->
						<th>字段名</th>
						<th>字段标识</th>
						<th width="150px">字段类型(长度)</th>
						<th width="100px">前台展示</th>
						<th width="100px">操作</th>
					</tr>
				</thead>
				<tbody>
                    <tr class="text-c">
						<td class="text-l">id</td>
						<td>主键 auto_increment</td>
						<td>int(10)</td>
						<td>是</td>
						<td class="td-manage">
							<a title="系统字段不可修改" href="javascript:void(0);" class="c-red" style="text-decoration:none">
								[系统字段]
							</a>
						</td>
                    </tr>
                    <tr class="text-c">
						<td class="text-l">category_id</td>
						<td>所属栏目id</td>
						<td>int(10)</td>
						<td>是</td>
						<td class="td-manage">
							<a title="系统字段不可修改" href="javascript:void(0);" class="c-red" style="text-decoration:none">
								[系统字段]
							</a>
						</td>
                    </tr>
                    <tr class="text-c">
						<td class="text-l">title</td>
						<td>标题</td>
						<td>int(10)</td>
						<td>是</td>
						<td class="td-manage">
							<a title="系统字段不可修改" href="javascript:void(0);" class="c-red" style="text-decoration:none">
								[系统字段]
							</a>
						</td>
                    </tr>
                    <tr class="text-c">
						<td class="text-l">userid</td>
						<td>发布人id</td>
						<td>smallint(10)</td>
						<td>否</td>
						<td class="td-manage">
							<a title="系统字段不可修改" href="javascript:void(0);" class="c-red" style="text-decoration:none">
								[系统字段]
							</a>
						</td>
                    </tr>
                    <tr class="text-c">
						<td class="text-l">username</td>
						<td>发布人</td>
						<td>varchar(20)</td>
						<td>否</td>
						<td class="td-manage">
							<a title="系统字段不可修改" href="javascript:void(0);" class="c-red" style="text-decoration:none">
								[系统字段]
							</a>
						</td>
                    </tr>
                    <tr class="text-c">
						<td class="text-l">create_time</td>
						<td>发布时间</td>
						<td>int(10)</td>
						<td>是</td>
						<td class="td-manage">
							<a title="系统字段不可修改" href="javascript:void(0);" class="c-red" style="text-decoration:none">
								[系统字段]
							</a>
						</td>
					</tr>
                    {foreach $table_extra_columns as $value}
                    <tr class="text-c">
						<!-- <td>{$value.id}</td> -->
						<td class="text-l">{$value.column_name_en}</td>
						<td>{$value.column_name_cn}</td>
						<td>{$value.type_length}</td>
						<td>{$value.is_show ? '否' : '是'}</td>
						<td class="td-manage">
                            <!-- <a title="修改" href="{:url('addOrEdit','id='.$value.id)}" class="" style="text-decoration:none"> -->
							<a title="修改暂不可用" href="javascript:void(0);" class="" style="text-decoration:none; color:gray;">
								[修改]
							</a>
						</td>
					</tr>
					{/foreach}
				</tbody>
			</table>
			<div class="text-r">
				{empty name="is_table"}
				<button type="button" class="btn btn-success radius" onclick="dropAndCreate({$table_id})">生成表</button>
				{else/}
				<button type="button" class="btn btn-danger radius" onclick="dropAndCreate({$table_id})">删除并重新生成表</button>
				{/empty}
                <!-- <button type="submit" class="btn btn-success radius" style="margin-left: 20px;">修改数据表</button> -->
                <button type="button" class="btn btn-default radius" onclick="layer_close();" style="margin:0px 20px;">返&nbsp;&nbsp;&nbsp;&nbsp;回</button>
            </div>
        </form>
    </article>

    <script type="text/javascript" src="/static/admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="/static/admin/lib/layer/2.4/layer.js"></script>
    <script>
        function dropAndCreate(table_id) {
            layer.confirm('此操作将删除表格(清空所有数据), 确认删除并重新生成该数据表吗？', function (index) {
                // console.log(table_id);
                $.post('/admin/data_table/dropAndCreateTable', {
                    'id': table_id
                }, function (data) {
                    if (data.code == 1) {
                        // $(obj).parents("tr").remove();
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1000
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 5,
                            time: 2000
                        });
                        return false;
                    }
                }, 'json');
            });
		}
		
		/*关闭弹出框口*/
		function layer_close(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
    </script>
</body>

</html>